package com.chenjj.etl.datatrans.converter;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;

/**
 * 数据字段
 */
public class DataMetaInfo implements Serializable {
    private int columnIndex; //编号
    private String columnName; //字段名
    private String columnType;//字段类型
    private int startIndex;
    private int endIndex;

    public DataMetaInfo(String line) {
        String[] columnInfos = line.split("[$$]");
        columnIndex = Integer.parseInt(columnInfos[0]);
        columnName = columnInfos[2];
        columnType = columnInfos[4];

        String columnIndex = columnInfos[6].replace("(","").replace(")","");
        String[] index = columnIndex.split("[,]");
        startIndex = Integer.parseInt(index[0]);
        endIndex = Integer.parseInt(index[1]);
    }

    public int getColumnIndex() {
        return columnIndex;
    }

    public void setColumnIndex(int columnIndex) {
        this.columnIndex = columnIndex;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getColumnType() {
        return columnType;
    }

    public void setColumnType(String columnType) {
        this.columnType = columnType;
    }

    public int getStartIndex() {
        return startIndex;
    }

    public void setStartIndex(int startIndex) {
        this.startIndex = startIndex;
    }

    public int getEndIndex() {
        return endIndex;
    }

    public void setEndIndex(int endIndex) {
        this.endIndex = endIndex;
    }

    @Override
    public String toString() {
        return "{columnIndex:" + columnIndex + "," +
                "columnName:" + columnName + "," +
                "columnType:" + columnType + "," +
                "startIndex:" + startIndex + "," +
                "endIndex:" + endIndex + "}";
    }
}
